<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>父组件向子组件传递数据</title>
</head>
<body>
<div id="app">
    <!--绑定的对象为子组件接收的变量，绑定的值为父组件中的变量-->
    <cpn v-bind:info="info"></cpn>
</div>

<template id="cpn">
    <h1>这是一个自定义组件</h1>
    <h2>来自父组件的数据：{{ info }}</h2>
</template>

<script type="module">
    import {createApp, ref, defineComponent} from "../../../js/vue.esm-browser.js";

    let component = defineComponent(
        {
            template: "#cpn",
            // 通过 props 选项来接收数据
            props: ['info'],
            setup() {
                return {}
            }
        }
    );

    let app = createApp(
        {
            setup() {
                let info = ref("Hello, Vue!")

                return {
                    info
                }
            }
        }
    );

    app.component("cpn", component)
    app.mount("#app")
</script>
</body>
</html>